<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<jsp:include page="../../include/top.jsp"/>
<script type="text/javascript">
    var editorIntro;
    KindEditor.options.filterMode = false;
    KindEditor.ready(function (K) {
        editorIntro = K.create('textarea[name="content"]', {
            filterMode: true,
            htmlTags: {
                span: ['.color'],
                p: [],
                strong: [],
                a: ["href", "target"],
                //br: [],
                img: ["src", "width", "height"],
                input: ['onclick', 'click', 'type', 'value', 'url', 'data-toggle', 'href', 'id', 'name', 'alt', 'data-ke-onclick', 'href', '/'],
                embed: ['src', 'name', 'id', 'width', 'height', 'type', 'loop', 'autostart', 'quality', 'style', 'align', 'allowscriptaccess', 'flashvars', 'allowfullscreen', '/'],
                vote: ['vote', '/'],
                video: ['id', 'name', 'src', 'controls', 'width', 'height']
            },
            newlineTag: "p",
            uploadJson: '${BasePath}/base/image/upload',
            items: ['undo', 'redo', 'image', 'multiimage', 'forecolor', 'bold', 'link', 'source', 'preview', 'fullscreen'],
            afterChange: function () {
                this.sync();
            }
        });
    });
</script>
<div class="main_body">
    <div class="span9 page_message">
        <section id="contents">
            <ul class="tab-nav nav">
                <li><a href="${BasePath}/web/news/list?${PublicParams}">公告新闻列表<span class="arrow fa fa-sort-up"></span></a></li>
                <li class="current"><a href="">添加/修改<span class="arrow fa fa-sort-up"></span></a></li>
            </ul>
            <div class="tab-content">
                <div id="tab1" class="tab-pane in tab1">
                    <!-- 表单 -->
                    <form class="form-horizontal" id="myForm" name="myForm" action="${BasePath}/web/news/save" method="post">
                        <input type="hidden" name="id" value="${bean.id }"/>
                        <div class="form-item cf toggle-orderFrom">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                标题：
                                <span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <input type="text" class="input-xlarge focused" name="title" id="title" value="${bean.title }">
                            </div>
                        </div>
                        <div class="form-item cf toggle-nick">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                文章类型：
                                <span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <select id="newsType" name="newsType">
                                    <option value="0" <c:if test="${newsType==0}">selected </c:if> >新闻</option>
                                    <option value="1" <c:if test="${newsType==1}">selected </c:if> >公告</option>
                                    <option value="3" <c:if test="${newsType==3}">selected </c:if> >活动</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-item cf toggle-password">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                资源来源：
                                <span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <input class="input-xlarge focused" id="sourceFrom" name="sourceFrom" type="text" value="${bean.sourceFrom}">
                            </div>
                        </div>
                        <div class="form-item cf toggle-password">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                作者：
                                <span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <input class="input-xlarge focused" id="author" name="author" type="text" value="${bean.author}">
                            </div>
                        </div>
                        <div class="form-item cf toggle-content">
                            <label class="item-label">
                                内容
                                <span class="check-tips"></span>
                            </label>

                            <div class="controls">
                                <label class="textarea">
                                    <textarea name="content">${bean.content}</textarea>
                                </label>
                            </div>
                        </div>
                        <div class="form-item cf">
                            <button class="btn submit-btn" id="submit" onclick="checkForm()" type="button">确 定</button>
                        </div>
                    </form>
                </div>
            </div>
        </section>
    </div>
</div>
<script type="text/javascript">
    function checkForm() {
        var title = $("#title").val();
        if (title == "") {
            layer.msg('标题不能为空!', {icon: 5});
            return false;
        }
        var sourceFrom = $("#sourceFrom").val();
        if (sourceFrom == "") {
            layer.msg('来源不能为空!', {icon: 5});
            return false;
        }
        var author = $("#author").val();
        if (author == "") {
            layer.msg('作者不能为空!', {icon: 5});
            return false;
        }
        $('#myForm').ajaxSubmit(function (data) {
            if (data.errno == 1) {
                layer.msg(data.errdesc, {icon: 5});
            } else {
                layer.msg('操作成功！');
                window.location.href = "${BasePath}/web/news/list?${PublicParams}";
            }
        });
    }
</script>
<jsp:include page="../../include/bottom.jsp"/>
